package com.mopa.qzone;
import java.net.URLEncoder;
import java.util.Iterator;

import android.os.Bundle;
public class WUtils {
	public static Bundle parseResult(String url,String mCallback)
	{
		String tmp = url;
		if (tmp.startsWith((new StringBuilder(String.valueOf(mCallback))).append("?#").toString()))
			tmp = tmp.substring(tmp.indexOf('#') + 1);
		else
			tmp = tmp.substring(tmp.indexOf('?') + 1);
		String array[] = tmp.split("&");
		Bundle bundle=new Bundle();
		int length=array.length;
		for (int i = 0; i < length; i++)
		{
			String item = array[i];
			String data[] = item.split("=");
			bundle.putString(data[0], data[1]);
		}
		return bundle;
	}
	public static String JointParamU(Bundle parameters)
	{
		if (parameters == null)
			return "";
		StringBuilder sb = new StringBuilder();
		for (Iterator<String>iterator = parameters.keySet().iterator(); iterator.hasNext(); )
		{
			String key = (String)iterator.next();
			sb.append((new StringBuilder(key)).append("=").append(URLEncoder.encode(parameters.getString(key))).toString());
			sb.append("&");
		}
		sb.deleteCharAt(sb.length()-1);
		return sb.toString();
	}
	
}
